图表功能 > 保存和导出C1Chart > 导出图表图像 |
您可以通过RenderTargetBitmap 方法导出图表的图像,如以下代码所示:
Visual Basic |
拷贝代码
|
---|---|
Dim bm As New RenderTargetBitmap(CInt(c1Chart1.ActualWidth), CInt(c1Chart1.ActualHeight), 96, 96, PixelFormats.[Default])
bm.Render(c1Chart1)
Dim enc As New PngBitmapEncoder()
enc.Frames.Add(BitmapFrame.Create(bm))
Dim fs As New FileStream("chart.png", FileMode.Create)
enc.Save(fs)
|
C# |
拷贝代码
|
---|---|
RenderTargetBitmap bm = new RenderTargetBitmap( (int)c1Chart1.ActualWidth,(int)c1Chart1.ActualHeight, 96, 96, PixelFormats.Default); bm.Render(c1Chart1); PngBitmapEncoder enc = new PngBitmapEncoder(); enc.Frames.Add(BitmapFrame.Create(bm)); FileStream fs = new FileStream("chart.png", FileMode.Create); enc.Save(fs); |